package com.sm.healthy.adapter

import android.graphics.Color
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.sm.healthy.R
import com.sm.healthy.data.bean.OxygenEntity
import com.sm.healthy.data.bean.Spo2Entity
import com.sm.healthy.databinding.ItemHistoryOxygenBinding
import com.sm.healthy.databinding.ItemHistorySpo2Binding

/**
 * 历史数据列表
 */
class HistorySpo2Adapter(
    layoutId: Int = R.layout.item_history_spo2,
    list: MutableList<Spo2Entity> = arrayListOf()
) : BaseQuickAdapter<Spo2Entity, BaseDataBindingHolder<ItemHistorySpo2Binding>>(
    layoutId,
    list
) {

    override fun convert(
        holder: BaseDataBindingHolder<ItemHistorySpo2Binding>,
        item: Spo2Entity
    ) {
        holder.dataBinding?.spo2Value = item

        when {
            item.spo2Ave <= 90 -> {
                holder.dataBinding?.textView14?.text = "↓"
                holder.dataBinding?.textView14?.setTextColor(Color.parseColor("#00aa11"))
            }
            item.spo2Ave in 91..93 -> {
                holder.dataBinding?.textView14?.text = ""

            }
            item.spo2Ave > 94 -> {
                holder.dataBinding?.textView14?.text = "↑"
                holder.dataBinding?.textView14?.setTextColor(Color.parseColor("#de253b"))
            }
        }
        when {
            item.pulseRateAve <= 60 -> {
                holder.dataBinding?.textView9?.text = "↓"
                holder.dataBinding?.textView9?.setTextColor(Color.parseColor("#00aa11"))
            }
            item.pulseRateAve in 61..99 -> {
                holder.dataBinding?.textView9?.text = ""
            }
            item.pulseRateAve > 100 -> {
                holder.dataBinding?.textView9?.text = "↑"
                holder.dataBinding?.textView9?.setTextColor(Color.parseColor("#de253b"))
            }
        }
    }
}